<script type="text/javascript">
$(document).ready(function() {
	$('#weight').priceFormat({  
        prefix: '',  
        centsSeparator: ',',  
        centsLimit: 3,  
        thousandsSeparator: '.'  
    });   
    
	$('#price').priceFormat({  
        prefix: '',  
        centsSeparator: '.',  
        centsLimit: 2,  
        thousandsSeparator: ''  
    });   
});

function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
        	$("#field").show();
            $('#imageBox')
            	.html("<img id='blah' src='"+e.target.result+"' width='250' height='300'/>");
        };

        reader.readAsDataURL(input.files[0]);
    }
}
</script>

<form enctype="multipart/form-data" id="new-productForm" class="form"
	action="../admin/new-product" method="post">
	<div style="width: 1024px; height: 600px; border: 1px solid windowframe;">
		<h2 class="partner-title" style="width: 100%;">Cadastro de Produtos</h2>
		<div style="width: 950px; margin: 0 auto;">
		<div class="box">
			<div class="cont">
				<div class="left">
					<label for="category">Categoria*</label>
				</div>
				<select id="category" name="id_category" class="required">
					<option value="">Selecione</option>
					<?php $categorias = $this->findAllCategories;
					for ($i = 0; $i < count($categorias); $i++) {
						echo "<option value=".$categorias[$i]['id_category'].">".$categorias[$i]['desc']."</option>";
					}
					?>
				</select>
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="title">Empresa*</label>
				</div>
				<select id="title" name="title" class="required">
					<option value="">Selecione</option>
					<?php $empresas = $this->findAllEnterprises;
					for ($i = 0; $i < count($empresas); $i++) {
						echo "<option value=".$empresas[$i]['enterprise_id'].">".utf8_encode($empresas[$i]['enterprise_name'])."</option>";
					}
					?>
				</select>
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="name">Nome*</label>
				</div>
				<input id="name" type="text" name="name" size="50" />
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="nat">Nacionalidade</label>
				</div>
				<input id="nat" type="text" name="nationality">
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="year">Ano de Lançamento</label>
				</div>
				<input id="year" type="text" name="year">
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="price">Preço*</label>
				</div>
				<input id="price" type="text" name="price">
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="quantity">Quantidade</label>
				</div>
				<input id="quantity" type="text" name="quantity" value="0">
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="weight">Peso</label>
				</div>
				<input id="weight" type="text" name="weight"> gramas
			</div>
	
			<div class="cont">
				<div class="left">
					<label for="desc">Descrição*</label>
				</div>
				<textarea id="desc" name="desc" rows="7" cols="50"></textarea>
			</div>
	
			<div class="cont">
				<div class="left">
					<label>Imagem</label>
				</div>
				<input name="image" type="file" size="30" id="image" onchange="readURL(this);"/>
			</div>
			<div>
				<input type="submit" name="send" value="Enviar"> <input type="reset"
					name="reset" value="Limpar Formulário">
			</div>
		</div>
		<div class="box" style="margin: 20px 0 0 60px; width: 35%">
			<fieldset id="field" style="display: none">
						<legend>Preview</legend>
						<div id="imageBox" style="margin: 10px 10px 10px 10px; text-align: center; "></div>
			</fieldset>
		</div>
		</div>
	</div>
</form>
